<template>
	<view class="tab_bar">
		
		<view class="tabbarBox">
			<view class="handleBox" v-for="(item,index) in tabBarList" :key="index">
				<view class="menuBox" v-if="item.iconPath!=='plus'" @click="goPages(item.pageIndex)">
					<view class="menuIcon">
						<uni-icons v-if="item.pageIndex!=selectIndex" :type="item.iconPath" size="30"></uni-icons>
						<uni-icons v-else color="blue" :type="item.iconPath" size="30"></uni-icons>
						<!-- <image v-if="item.pageIndex.index!=selectIndex" class="img" :src="item.iconPath"></image>
						<image v-else class="img" :src="item.selectIconPath"></image> -->
					</view>
					<view class="menuName">
						<text :class="item.pageIndex.index==selectIndex?'TextColor':'Text'">{{item.tabbarName}}</text>
					</view>
				</view>
				<view v-else class="menuBox" @click="addJz">
					<view class="menuIcon">
						<uni-icons v-if="item.pageIndex!=selectIndex" :type="item.iconPath" size="30"></uni-icons>
						<uni-icons v-else color="blue" :type="item.iconPath" size="30"></uni-icons>
						<!-- <image v-if="item.pageIndex.index!=selectIndex" class="img" :src="item.iconPath"></image>
						<image v-else class="img" :src="item.selectIconPath"></image> -->
					</view>
					<view class="menuName">
						<text :class="item.pageIndex.index==selectIndex?'TextColor':'Text'">{{item.tabbarName}}</text>
					</view>
				</view>
			</view>
		</view>
	</view>
	
</template>

<script>
	export default {
		props: {
			page: {
				type: String,
				default: "/pages/tabbar/tabbar-1/tabbar-1"
			}
		},
		watch: {
			page: {
				handler(value) {
					this.selectIndex = value;
				},
				immediate: true,
				deep: true
			}
		},
		data() {
			return {
				selectIndex: "",
				tabBarList: [{
						tabbarName: '明细',
						iconPath: 'settings-filled',
						selectIconPath: "settings-filled", //tabbar 选择icon
						pageIndex: '/pages/tabbar/tabbar-1/tabbar-1'
					},
					{
						tabbarName: '图表',
						iconPath: 'folder-add-filled',
						selectIconPath: "folder-add-filled", //tabbar 选择icon
						pageIndex: '/pages/tabbar/tabbar-2/tabbar-2'
					},
					{
						tabbarName: '记账',
						iconPath: 'plus',
					},
					{
						tabbarName: '账单',
						iconPath: 'compose',
						selectIconPath: "compose", //tabbar 选择icon
						pageIndex: '/pages/tabbar/tabbar-4/tabbar-4'
					},
					{
						tabbarName: '我的',
						iconPath: 'person-filled',
						selectIconPath: "person-filled", //tabbar 选择icon
						pageIndex: '/pages/tabbar/tabbar-5/tabbar-5'
					}
				],
			}

		},
		//uniapp子组件不支持应用生命周期，所以只能用vue生命周期
		created() {


		},
		methods: {


			//进入tabble页
			goPages(pageIndex) {
				console.log(pageIndex)
				uni.switchTab({
					url: pageIndex
				})
			},
			addJz() {
				this.$emit('addCheck')
				console.log('jizh')
			}
		},
	}
</script>
<style lang="scss">
	.tab_bar {
		width: 100vw;
		height: 120rpx;
		position: fixed;
		bottom: 30rpx;
		/* 模糊大小就是靠的blur这个函数中的数值大小 */
		backdrop-filter: blur(10px);
		border-radius: 60rpx;

		.tabbarBox {
			display: flex;
			margin-top: 10rpx;
			justify-content: space-evenly;


			.handleBox {
				width: 20vw;
				height: 110rpx;


				.menuBox {
					padding: 0rpx 20rpx;
					width: 120rpx;
					height: 98%;
					text-align: center;

					// .img {
					// 	width: 50rpx;
					// 	height: 50rpx;
					// }
					// .icon_se{
					// 	color: red !important;
					// 	background-color: yellow  !important;
					// }
				}
			}
		}
	}

	.Text {
		font-size: 24rpx;
		font-family: Cochin, serif;
		font-weight: 900;
	}

	.TextColor {
		@extend .Text;
		color: #d81e06;
	}
</style>